import QtQuick 1.0
//import ShellInvoker 1.0
import "../../../common/lib/kdeadmouseutils-build-desktop"


FocusScope {
  height : 700
  width : 1024
  state:''
  focus:true
  //id:mainItem
  Videoplayer {
    id:player
    height : parent.height
    width : parent.width
    anchors.left:mSelector.right
    
  }
  
  HListMovie {
    id : mSelector
    height : parent.height
    width : parent.width
    anchors.left : parent.left
    focus:true
    
  }
  QmlSetting{
    id:setting
    appName:'allocine'
  }
  Connections {
      target: mSelector.detailQml
      onAction : {
	//console.log('ask for '+type + ' with' + mSelector.detailQml.currentObj.title);
	state='movieView';
	var mType;
	var mCode;
	if(type=='trailer'){
	  mType='trailer';
	  mCode=mSelector.detailQml.currentObj.trailerCode
	}else if (type=='play'){
	  mType='direct';
	  mCode=setting.value('magikPrefix')+mSelector.detailQml.currentObj.url;
	}else{
	  return;
	}
	if(!mCode||mCode=='')
	  return;//TODO : desactiver bouton
	
	console.log('mCode:'+mCode);
	console.log('mType:'+mType);
	appControl.videoBackground=true;
	backgroundVideo.stop();
	player.mediaType=mType;
	player.codeMedia=mCode;
	player.wget.startDwnld();
      }
  }
  Connections {
      target: player
      onRetour : {
	console.log('ask retour');
	state='';
	backgroundVideo.stop();
	appControl.videoBackground=false;
	mSelector.focus=true;
      }
  }
  
  states: State {
		name: 'movieView'
		AnchorChanges { 
		  target: mSelector 
		  anchors.right : parent.left
		  anchors.left :''
		}
		PropertyChanges { target: player;focus:true}
		
	}
  transitions: Transition {
	AnchorAnimation { easing.type: Easing.InOutQuad }
      }
  
}